In [2]:
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
In [3]:
#these are global, you should probably just add them to
#an rc file, which will make them perminant.
plt.rc('text', usetex=True)
plt.rc('font', **{'family':'serif','serif':['Computer Modern']})
In [10]:
x = np.linspace(0,5)
y = x**2
xdata=np.linspace(0.5,4.5,10)
dy=(2*(np.random.random_sample(size=10)-.5))
ydata = (xdata**2)+dy
In [12]:
fig, axes = plt.subplots()
axes.plot(x, y, 'r')
axes.set_xlabel('x')
axes.set_ylabel('y')
axes.set_title('title');
In [11]:
fig = plt.figure()
axes = fig.add_axes([0.1, 0.1, 0.8, 0.8]) # left, bottom, width, height (range 0 to 1)
axes.plot(x, y, 'r')
axes.set_xlabel('x')
axes.set_ylabel('y')
axes.set_title('title');
In [ ]:
In [9]:
axes.errorbar?
In [18]:
#%matplotlib qt #use to find coordinates in plot
%matplotlib inline
fig , axes = plt.subplots()
axes.set_yscale('log')
axes.plot(x, y, color='k', label='fit',linewidth=2)
#By setting the autoscale off, we can add in scatter data
#without pushing the scale off the edge of the plotted line
axes.set_autoscale_on(False)
axes.errorbar(xdata,ydata,dy,color='k',label='data',fmt='.k')
axes.text(0.5, 0.1, r"$y=x^2$", fontsize=12, color="k")
#axes.axis('tight')
axes.set_xlabel('x')
axes.set_ylabel('y')
axes.set_title('title')
axes.legend(loc='best');
In [8]:
# A histogram
n = np.random.randn(100000)
fig, axes = plt.subplots()
#It would be nice to have a hard black outline... but it's probably not worth my time.
axes.hist(n,color='grey',alpha=0.5,histtype='stepfilled');
In [76]:
axes.hist?
In [ ]: